<?php
/**
 * @title 1711. 大餐计数 - 双循环+缓存
 * @author start2004
 */

class Solution {

    /**
     * @param Integer[] $deliciousness
     * @return Integer
     */
    function countPairs($deliciousness) {
        /**
         * @since 2021-07-07 缓存两两菜品组合结果
         */
        $cacheArray = [];

        /**
         * @since 2021-07-07 符合菜品的总数
         */
        $cnt = 0;

        /**
         * @since 2021-07-07 双循环
         */
        for($i=0, $len=count($deliciousness); $i<$len; $i++){
            $m = $deliciousness[$i];
            for($j=$i+1; $j<$len; $j++){
                /**
                 * @since 2021-07-07 大数在前
                 */
                $n = $deliciousness[$j];
                if($m>=$n){
                    $k = "{$m}_{$n}";
                } else {
                    $k = "{$n}_{$m}";
                }

                /**
                 * @since 2021-07-07 查找缓存
                 */
                if(!isset($cacheArray[$k])){
                    /**
                     * @since 2021-07-07 是否2的幂
                     */
                    $r = log($m+$n, 2);
                    if($r == intval($r)){
                        $v = 1;
                    } else {
                        $v = 0;
                    }

                    /**
                     * @since 2021-07-07 缓存
                     */
                    $cacheArray[$k] = $v;
                } else {}

                /**
                 * @since 2021-07-07 统计
                 */
                $cnt += $cacheArray[$k];
            }
        }

        /**
         * @return
         */
        return $cnt%(pow(10, 9)+7);
    }
}

/**
 * @url http://127.0.0.1/leetcode/202107/2021.07.07.php
 */
$datas = [
    // [[1,3,5,7,9]], // 4
    // [[1,1,1,3,3,3,7]], // 15
    [[269731,778845,193336,330952,964,60,5,11,874888,173688,61,67,118079,12993,1,0,13594,19174,1,7,132740,391548,6,2,365,659,1,3,54434,994142,3706,390,767,3329,249,7,346,166,3464,4728,417,95,7816,376,517,7675,1504,14880,9,7,0,4,16,16,3,1,29,35,283,741,5,11,1211,837,27607,5161,4112,4080,6596,26172,4,0,110,146,735528,313048,8,0,3017,5175,881,143,0,1,129,127,11580,21188,7,1,488472,35816,31804,99268,1680,14704,7,9,21,107,193,63,19,13,55,4041,589,435,11156,5228,114,14,72,8120,329529,719047,544,32224,919,3177,1394,654,6958,1234,202,54,109,147,50202,998374,200,1848,1459,2637,6,2,108,404,63,65,1128,2968,49825,81247,63135,2401,3169,927,2,0,70,58,128,384,168,88,9824,55712,23185,238959,31,1,76495,54577,21948,10820,2,0,4,0,1621,2475,29652,3116,56858,8678,0,2,13581,51955,1,1,14803,17965,1,1,499,525,681,343,208539,53605,9282,23486,204653,319635,2,0,1,3,312680,211608,1,7,80,176,14,2,3285,811,3,1,1106,942,362,662,42825,88247,5712,10672,511608,12680,218055,306233,93,163,207,49,4,60,26997,38539,20,44,3892,4300,5698,125374,57,71,121,7,122,134,366,1682,1263,31505,168699,355589,226934,35210,10045,55491,7411,781,2674,1422,14,18,174,82,21203,11565,0,4,7,9,121,7,0,1,1,1,2970,1126,74807,973769,94,1954,1226,822,1,0,9075,7309,23189,9579,10,6,6,2,35,29,4609,3583,225590,298698,1155,2941,3926,4266,841,3255,2819,29949,15,1,16005,379,6351,1841,13562,19206,197618,326670,82,430,243,269,8,8,56,456,0,1,27402,234742,30457,100615,226235,35909,0,1,428,84,1,1,1,1,4,0,275,7917,0,32,2072,6120,37,475,47,17,77326,184818,3737,359,54,10,4,28,431684,92604,2141,1955,7409,8975,309,715,290,222,0,1,961396,87180,0,1,5,27,6896,1296,0,2,1,1,22,42,143893,118251,17,15,44,212,649,375,0,8,19922,45614,3535,561,1415,2681,43703,21833,693501,355075,623,401,20247,12521,479,545,4,12,14514,1870,1120,7072,30,226,3667,4525,2,0,79,49,7064,25704,100,156,41,4055,2,0,415,97,709340,339236,164,348,7384,9000,111777,936799,3,5,708,316,1,0,4,28,1,0,51,77,32,32,837,187,88417,435871,939003,109573,35915,95157,406707,117581,21,11,1712,2384,38,26,391824,132464,148,364,535,489,0,4,1,1,310,202,10,54,255,1,79855,51217,13533,2851,515733,8555,0,2,363,1685,4551,28217,2,6,394401,654175,119,9,129,127,1,63,69008,193136,677,347,15992,392,6,250,500,524,979,3117,2250,30518,6810,1382,9450,6934,191,65,17948,113124,9783,121289,32,96,1690,358,3490,4702,0,2,3539,557,31,1,217,39,378,7814,17365,113707,23904,107168,14620,18148,1417,522871,1,7,64,448,23,9,1622,6570,17,15,7136,58400,36,92,113,15,40813,221331,1830,6362,88,40,7,121,54,74,1,1,415540,108748,345,167,1459,589,5,27,22940,1025636,29,3,221,7971,32,32,1902,6290,662,3434,2,254,207671,54473,1,3,0,2,102583,28489,455185,69103,245185,16959,1,0,46,466,8,0,700,324,4,0,57,199,483078,565498,3,1,54,10,1415,2681,0,1,205,307,2307,1789,45715,19821,10784,5600,1000,24,0,16,0,2,171239,877337,57514,466774,1,3,363,149,689,7503,207,49,0,4,4,60,3,13,1,0,6426,9958,2882,1045694,7,1,0,2,175,81,110931,413357,275,237,1,1,635,389,96252,34820,668,1380,6587,1605,191,833,29,3,0,1,0,2,66,62,31,33,1,7,10152,55384,211,301,1,0,9,7,79,49,13,19,194274,67870,11,5,76613,54459,1,0,28,4,7936,24832,15185,50351,5151,3041,45,19,6489,1703,9,23,488878,35410,1342,6850,7,249,29,99,14,242,6265,26503,108194,22878,1,3,5991,10393,22,10,2913,29855,78277,183867,4665,3527,3195,62341,69356,61716,299015,225273,434,78,8804,7580,336,176,0,4,392,1656,9,7,97,159,189,835,0,2,52414,78658,0,8,817,207,242,270,0,1,489,23,31,33,69125,979451,24,8,1,1,281522,242766,78,178,23,41,149667,898909,0,4,1115,933,7,1,7797,395,260,1788,12,20,5063,60473,50,14,208,816,11,21,1,0,0,2,245125,17019,3247,849,187,325,67266,63806,2,0,104158,26914,28,4,1,1,7,1,231,793,23466,9302,202910,321378,1,7,12077,4307,103504,158640,144,368,1520,6672,12,4,9350,7034,61,963,0,2,21888,10880,50635,14901,3929,4263,1190,2906,228,28,0,1,90356,958220,2139,1957,47,17,12,4,0,4,174395,87749,1,1,9698,23070,2,0,148,364,2,2,520634,3654,2,0,483,29,0,2,16005,379,1,1,4702,11682,1,0,8,8,8,0,1856,192,477490,46798,5,3,13599,2785,5093,3099,675,1373,46147,478141,829919,218657,111,17,48,208,231,281,19,13,3585,511,442428,81860,61,67,1,7,12117,20651,2,2,147,109,800774,247802,0,1,2,0,138494,910082,5,4091,520558,3730,6672,1520,21501,11267,6845,9539,4,28,11864,1036712,205159,319129,15848,536,695821,352755,3227,869,19,45,0,1,86508,44564,6,10,1,0,45433,216711,1,0,89975,434313,53197,77875,10179,22589,402,110,251375,272913,0,4,31076,1692,180480,343808,17353,48183,0,1,31785,983,384,640,109858,21214,27444,38092,30217,2551,0,1,575690,472886,72,184,0,1,31,1,1,15,0,4,1,1,40,24,74114,56958,1,1,4,0,879,145,4,4,44475,86597,3,1,1,1,1,15,157,355,13,3,0,4,0,4,435,1613,2,2,115,13,4,0,370629,677947,15,1,14499,18269,2124,1972,0,1,10375,22393,4,12,867,31901,0,2,11,5,102,154,16825,48711,1,3,218,38,3,1,3,253,40,88,26,38,102716,28356,40512,25024,367385,156903,0,2,8,0,0,2,57359,204785,877,147,440397,83891,12,20,543,1505,170831,91313,461297,62991,0,1,3,5,44,468,411,101,119564,11508,0,1,7,1,2,0,349356,174932,674,1374,975,49,562349,486227,697548,351028,423003,101285,3066,1030,1785,6407,73,1975,675,349,25527,7241,2,0,68,188,1,7,332,692,1,1,72903,189241,6689,9695,0,32,3073,1023,30226,2542,197,315,52954,471334,3175,921,14692,18076,830,15554,269,243,14842,50694,1269,779,249991,12153,282,230,4,12,85,43,816,208,1,0,3,1,27,5,25,39,3706,4486,56987,8549,57411,73661,277,747,46810,215334,24,8,41400,24136,7879,313,0,8,53,75,1888,160,10,6,33828,31708,62,194,234,278,812,212,105,151,5487,2705,2,0,8,0,21246,11522,58,198,108808,22264,90255,958321,0,8,0,1,385,3711,6349,1843,13112,3272,12040,4344,7,2041,108839,153305,151,105,67,61,262029,786547,47666,17870,1,7,7609,583,3187,13197,26,6,1,3,3,5,197,59,1,0,2584,13800,1,1,39550,484738,1,0,61,67,125021,6051,24,232,19,13,438237,86051,208,48,921755,126821,177199,871377,322,702,6682,1510,1,1,49,79,19,45,0,1,1,1,71774,190370,81218,49854,4,12,57136,73936,39328,222816,59462,6074,84800,177344,1,0,412,100,26192,6576,1,3,405,32363,0,2,303,7889,23,9,3,1,267,3829,26502,6266,1,1,45,211,1,0,114355,409933,32227,541,66960,457328,61246,463042,12,4,37,219,2927,1169,3,1,27,5,253,771,3470,626,2,0,2,0,94,162,1,1,63075,461213,4,0,6,2,7268,924,113,399,7757,25011,13269,117803,28,100,15,1,262215,786361,66278,64794,1266,2830,0,1,105,23,1125,923,3056,1040,239,17,4,0,32,0,462873,61415,598,130474,28734,4034,97559,33513,52809,12727,30,2,0,2,122157,926419,154456,107688,8,8,0,1,1,0,521771,526805,2780,5412,349279,175009,19,13,1402,6790,200656,61488,815,209,235,21,119990,142154,0,16,104,1944,5,11,0,1,104287,944289,128523,395765,24805,7963,1,0,714,1334,29227,36309,543786,504790,116,12,3189,5003,15753,49783,46,18,1,7,4827,11557,2574,1522,500,12,480204,44084,26980,235164,723009,325567,1,3,404,108,15,1,98,414,4,4,7685,8699,21007,11761,3,1,111741,19331,777021,271555,2,0,554,470,85,43,8,8,11,5,20202,12566,958,66,255884,6260,8,8,15602,782,731,293,125656,136488,1163,885,585550,463026,763,261,1,1,1281,2815,39,25,37,27,3,13,1550,498,688,336,11717,4667,6189,2003,23,9,4,4,3,5,1,0,79,945,692,1356,5,2043,519981,4307,775243,273333,0,2,344556,179732,4006,90,17,15,189909,72235,1908,14476,57,455,2,0,1,0,5785,2407,0,1,466464,582112,274,750,26,102,10327,120745,13,3,2,0,9,7,1,63,1033,3063,0,16,12778,19990,1923,6269,8,0,0,32,29,99,507,5,546,3550,1,0,41,23,120,904,0,2,2,2,152801,371487,1633,415,55,9,170,86,10897,5487,89071,435217,45,19,307,205,40,24,78011,184133,702100,346476,1727,2369,5244,2948,120079,10993,56,72,609507,439069,3,1,0,1,6,2,3164,932,7273,919,77,179,146678,115466,1,3,1,3,230,282,150458,111686,157,1891,2991,1105,2,6,0,4,908442,140134,11,5,45,83,8755,7629,3,1,0,32,105671,156473,397,627,218,294,0,2,12899,52637,128,128,3,1,114,398,0,8,516182,532394,5283,27485,351068,697508,10058,55478,754,270,477,35,904,1144,2932,29836,14210,18558,4,0,0,8,8,24,0,1,179,77,12546,20222,1129,919,1471,577,656,1392,17889,113183,25198,7570,16,16,12,20,56958,205186,0,4,48,16,132,124,52426,78646,0,2,494,530,33,31,55,73,5,3,4,0,12166,20602,7,25,516,3580,258296,3848,12,20,29303,3465,65261,459027,4091,5,2,2,644,380,3,1,1,0,1,0,242438,19706,118,10,9294,56242,1537,2559,113817,17255,115,141,8,56,1,7,4,12,1669,379,30,34,389,1659,436741,87547,668,32100,12544,3840,0,16,7885,307,67,189,23010,9758,0,2,819971,228605,6607,1585,7,1,84088,46984,2892,5300,13,19,1,1,104,24,587,437,4388,3804,253,771,189,67,196919,65225,2,14,54875,10661,1768,280,47105,83967,804,220,3232,4960,0,1,0,1,1271,2825,215,41,1012,1036,706,318,16,16,6876,1316,0,1,501,523,432647,91641,422451,626125,233227,815349,15109,17659,1,1,2,2,50,14,3,5,3,1,126,130,2,14,960,64,29,3,20368,12400,1439,609,57,199,33,223,61862,3674,4158,4034,10,6,31766,1002,9,23,2353,30415,5,27,225,31,0,4,119804,11268,16,496,17,47,0,2,1,3,1603,2493,8,120,46789,215355,26143,6625,13161,19607,4,12,0,2,19,13,2,2,75,53,2022,26,2,2,2,0,222816,39328,0,2,1629,2467,16,48,6,2,1,1,89,39,17,15,2,6,207,49,1339,15045,4,508,405161,643415,25,103,956,3140,52554,78518,196,316,5,3,0,1,14,2,114,398,17,47,4140,61396,207,49,89184,172960,119,137,7,9,252,32516,29633,35903,105,23,115923,408365,1,1,152400,109744,3287,29481,7,1,9086,7298,3647,127425,20050,45486,29661,3107,15370,1014,936,1112,9,7,778049,270527,71,57,81,47,16029,49507,2,0,7,57,0,1,206,818,3543,127529,1,0,11,21,128,128,437,75,77,179,1,1,62,2,196,828,0,8,3307,789,6,26,0,1,221983,826593,17144,48392,981,43,2654,5538,1,0,377,135,2,6,143459,118685,17540,47996,1,0,7024,9360,44,20,24,40,1089,31679,3392,704,6,10,0,2,7215,977,95,929,4589,28179,4971,11413,53178,995398,3959,28809,2263,1833,13745,51791,3,1,8039,153,2,0,221633,40511,13,3,2805,1291,2,0,2009,39,125,387,2679,1417,8,56,9,1015,1,3,45705,19831,0,8,0,2,36,28,1,1,73350,57722,1,0,43256,22280,3,13,1,0,2585,5607,7420,8964,115440,146704,32,224,891,1157,15,17,30,2,34073,31463,3921,4271,375,649,295,1753,318686,205602,31,1,44650,86422,13662,51874,119,393,31092,99980,233,23,230681,293607,25,103,129017,395271,6,2,8,0,7,1,15614,17154,29,3,0,32,45018,20518,0,8,1337,711,50876,80196,862,162,21,11,5,3,208023,54121,599530,449046,117,395,111,145,5157,125915,12620,20148,39,25,7246,946,527,497,4,28,44917,20619,2,0,207231,54913,425427,623149,3138,13246,53,203,4,0,2497,5695,0,1,65,447,12,20,171400,877176,9,7,23,105,1,0,2660,1436,223,33,12390,1036186,25543,39993,3489,607,1,0,163257,98887,37,91,1381,667,3970,126,3,13,0,2,71617,452671,753,271,4984,11400,5911,2281,0,64,919775,128801,22,10,4612,3580,18068,47468,373,651,23198,107874,1,7,1006,15378,120,8,101172,29900,219,37,314,1734,2,0,2,30,161,95,16281,114791,1562,486,30362,2406,797222,251354,22,10,1283,765,90669,171475,3736,4456,536583,511993,454238,70050,939,85,7,1,8,0,1889,159,60934,70138,499812,548764,27,101,380,644,0,1,8149,43,473079,575497,8,24,53,203,9004,7380,11293,21475,0,1,785711,262865,64,0,25243,40293,2960,1136,501,523,95,1953,279888,244400,833982,214594,16029,246115,4,4,3,5,420,92,17,15,504,8,328051,196237,15,1,346,1702,4476,126596,0,1,36619,28917,1,0,1,7,1,0,2,6,0,8,71,57,3,1,285254,239034,506790,17498,28,4,10,6,2828,1268,1,0,1338,710,8407,57129,32,0,358879,689697,337,1711,472,40,21417,11351,5049,3143,29,35,135,121,1,0,1,0,5,11,151,105,2,0,1096,952,3686,410,9621,23147,223,289,60431,70641,2,0,15434,950,5213,27555,350,162,43749,87323,4,4,2069,6123,2,2,1,1,73171,57901,1,7,32955,32581,1258,2838,15,17,552,472,1094,954,692,332,451,61,620,3476,120,8,5,3,57,7,78047,184097,18781,13987,18,46,196,316,9,7,183,1865,19,13,2,14,24209,8559,3445,29323,216,40,2,30,1,1,171078,91066,74,54,2349,14035,37,27,6520,9864,75344,448944,26,38,26095,6673,241971,20173,1130,918,219,37,481,31,2,0,22392,10376,156,100,2,0,1061,3035,354790,693786,67697,194447,49,15,22,42,19,13,412937,111351,486,1562,16,16,10,118,1,0,10006,55530,9086,7298,4572,11812,19071,13697,693,331,3937,159,5,11,8,120,5954,10430,1,0,47,17,14,2,158641,889935,116,396,4261,3931,2,0,0,1,654,370,203,53,5,11,1745,2351,857,167,27,5,150592,373696,1,7,58780,72292,11,5,4491,11893,6622,1570,734189,314387,22,106,1564,484,14307,116765,675,349,53,11,1367,681,387,125,8677,7707,84,44,19665,45871,1806,242,3,1,286872,237416,4,4,185,71,165,347,24,40,166679,95465,471570,52718,137,119,236,20,92,164,1180,31588,90,38,109,19,56417,205727,832,15552,2022,6170,1994,54,163280,98864,437,3659,97,31,0,2,305,3791,6,58,99,29,1,0,0,1,23152,42384,1575,2521,1685,2411,170558,91586,49,15,0,128,6,58,31125,1643,7930,8454,36022,95050,168294,93850,86719,961857,62428,3108,78,50,1654,6538,1144,7048,9367,7017,12,52,1,0,53,75,160,96,4,0,339,173,3,1,2,2,27,37,893037,155539,4962,3230,1,3,1321,727,4,12,1681,2415,1,0,292341,231947,1,0,230324,293964,19,109,525888,522688,808,216,58,70,46,18,21,43,1531,517,31801,33735,1,0,48,80,1644,2452,6,10,1667,381,29589,3179,107277,23795,50,14,32032,99040,1194,854,3470,626,2664,13720,1887,161,18,46,633857,414719,23974,8794,802952,245624,81644,49428,3898,198,0,2,946184,102392,6939,9445,302064,222224,4,4,49,79,270,242,0,1,435094,89194,87,425,1176,7016,1,0,1339,709,134,122,701301,347275,55,73,417,7775,202,54,18,110,0,2,1640,2456,13296,3088,49,463,944187,104389,78238,183906,29784,35752,14353,2031,182153,79991,2,0,3913,183,2,6,707,3389,4,252,508,4,3722,12662,3,5,3149,947,102228,159916,167,857,0,1,42,214,8079,8305,104,8088,59851,464437,21760,109312,7240,952,2699,128373,891,1157,810833,237743,89,39,68,60,0,4,1,0,118581,12491,3182,914,97569,33503,106,22,430,594,9,119,111998,412290,47114,18422,1,31,4,0,16,0,6,58,1,7,7615,25153,707,15677,27,229,32,0,1808,2288,985,39,715,7477,25,7,3755,12629,146,366,10,6,358,154,3,1,1151,897,18,8174,747400,301176,2,6,10841,120231,1,0,1420,2676,17,495,43,85,1,3,1713,2383,225,287,15951,16817,476,3620,3,5,15922,16846,10,6,0,1,0,1,567542,481034,13261,117811,1,3,134,378,1447,14937,9,7,7,9,7674,57862,2,30,16416,16352,31063,34473,1720,328,172046,90098,17952,506336,6,26,752346,296230,99,29,13803,51733,0,1,50,462,2,2,354553,169735,60515,5021,3654,442,5918,2274,0,32,7043,9341,202943,845633,599617,448959,1,7,119496,11576,3,5,3558,4634,15,1,28225,37311,75,53,30,34,2,2,179393,82751,956,68,85,171,1911,2185,1040,1008,1,1,871024,177552,12300,511988,703,321,4,60,2072,6120,481,31,17,15,31636,230508,161083,363205,58,966,1,0,29,35,0,8,7,25,450617,73671,173,83,97639,33433,1,0,8,8,53,75,0,1,0,1,1227,6965,4,0,104627,26445,58,198,712,312,1,255,473673,50615,610,414,15,49,18,1006,776,248,2,0,1835,213,14284,2100,830507,218069,730,294,427,85,17,15,3,1,1615,2481,0,1,544,3552,567,457,7,9,165091,883485,0,1,354,158,3519,577,14232,2152,52,12,0,1,80692,181452,17715,15053,27,5,10,22,37,27,14051,2333,112,144,4,0,142,16242,29976,2792,36740,94332,0,1,3078,5114,4394,28374,1,0,1439,609,0,4,4,60,2247,14137,12205,118867,6,2,9404,23364,7,1,3477,619,31,1,223,33,0,2,670576,378000,4,28,15,17,13,1011,41043,24493,18675,14093,75,181,8,8,19,237,1,3,0,2,0,1,86,426,47,17,8,0,145746,378542,1464,6728,18041,244103,198077,326211,3,1,1,15,29,35,2,2,158038,366250,0,2,1031,64505,28525,4243,1954,94,13,3,11,117,13,3,621,1427,106525,24547,1280,2816,169269,355019,16,0,3962,4230,1,0,915,109,6015,10369,2,2,28,4,116042,932534,56656,8880,212,44,14466,18302,1,0,1204,31564,0,256,8,0,326,3770,7,9,292751,231537,8,0,0,2,446,66,98,30,1001,3095,1,1,836,188,1719,2377,22764,10004,8,24,650,1398,0,1,436145,88143,2,0,551,1497,21,43,788,15596,0,1,62,2,27,5,9,7,10305,120767,484,28,154,102,107119,23953,183674,78470,462,50,1872,6320,563,461,18504,14264,108,404,6,10,274,238,101,27,16,0,163968,360320,5258,2934,35,93,62,194,425391,98897,57,7,237,19,28,4,139428,122716,61315,4221,308,716,14,2,1,1,1042,7150,2137,6055,1549,499,23807,8961,3,5,1,0,0,64,405,107,1041,1007,0,64,117,11,0,32,1,7,20,492,51,13,78,178,3294,802,457902,66386,127336,921240,2,0,9348,56188,38103,27433,1380,522908,0,1,145455,378833,222075,302213,475,549,2,6,4764,11620,0,2,18,14,282,1766,145752,116392,864,1184,85,171,179208,869368,802,3294,144,368,88173,960403,1,3,146324,115820,4,4,1,7,299097,225191,33276,228868,8,0,1416,632,3942,154,28699,36837,5,11,459332,64956,416296,107992,49,463,5,11,55173,10363,55,9,6,2,251,1797,150308,373980,1644,6548,228,284,1666,382,269,755,96,32,63,1,1,0,3169,5023,373,139,15918,466,4,0,153657,370631,11338,250806,226091,36053,13014,52522,13115,19653,140052,908524,935371,113205,16566,16202,7,1,214,42,2896,13488,191,8001,1,0,2541,13843,1995,53,1,1,23946,1024630,193379,330909,243,269,1,0,24796,40740,0,1,53,11,223,801,177,79,1,63,178993,345295,58776,6760,1,3,51531,14005,94797,953779,0,4,4,0,16009,508279,0,1,1,0,80,176,1,1,70,58,1,1,2611,13773,405842,118446,4,4,2858,13526,2,0,5,3,126,2,275,237,27576,5192,295,1753,460,52,8183,9,5,3,15,49,2,2,1358,690,285944,238344,22251,10517,1096,952,13,3,15559,17209,8,8,3897,61639,67,445,14791,1593,448707,75581,228607,33537,3,5,155876,106268,454144,70144,0,1,0,1,1368,31400,18522,505766,1697,6495,314,198,0,128,658384,390192,888,136,0,2,10758,5626,381,1667,23,9,7,25,16873,15895,14,2,10,22,2,2,0,2,0,1,4,12,239,273,418357,105931,27,101,21001,44535,1576,2520,3,1,3981,4211,354,158,99075,31997,57947,7589,46004,85068,19,13,15964,49572,14,2,684480,364096,9,7,3,1,140087,384201,57,71,28212,233932,15321,1063,287,1761,14,18,13,3,46059,85013,57,455,568,456,15,1,1272,776,249,263,83,173,671,353,199850,62294,8,0,19576,242568,253430,795146,26,38,11,5,456,568,119630,142514,13273,3111,1,3,121,7,524,1524,5344,2848,0,2,58,70,10694,5690,240,16,2563,13821,383,3713,430607,617969,191,3905,1,0,17262,15506,254118,8026,229,27,42,22,116555,14517,210143,838433,190,66,65,63,13138,19630,78650,52422,1,3,1,0,94197,167947,60,4,0,2,941,83,166,90,1,31,0,1,6,10,13252,117820,148,108,12986,52550,846,1202,96,32,7304,9080,224,32,730,294,190077,72067,1,0,1838,2258,53370,208774,34,94,129017,2055,342631,181657,3,13,32,32,3,1,117,139,5,123,21,235,55,9,20,12,178329,345959,80949,50123,61,67,24,8,261550,594,48874,82198,184743,863833,0,1,48,16,16153,49383,0,4,19413,13355,2,2,9,119,961,63,79837,182307,704487,344089,471,41,3956,140,4,12,48579,16957,487,1561,868,1180,1,1,9496,6888,7,57,388,636,147,109,3038,5154,39,25,47729,83343,158,98,199,57,2048,2048,316,196,0,8,11853,4531,74,182,0,1,4,0,32,0,13,3,28683,102389,1,15,170,342,14390,1994,42,22,100836,423452,6,2,2,6,87819,174325,1133,31635,24,488,1,0,3589,520699,96,32,118212,12860,4,4,2,2,394,118,0,64,0,2,71,441,124,32644,134,378,9,7,3780,4412,3,29,1,1,257,3839,14,2,423680,100608,12088,20680,2,2,2,2,27,5,8,8,74,182,53,75,7687,57849,1419,629,2842,13542,538,1510,409619,638957,376178,148110,34053,97019,15,49,100,156,17604,15164,16,16,1,3,93568,168576,38,26,1777,271,2,2,27,101,28,228,165643,358645,13,3,174313,87831,58455,203689,96789,951787,83,45,858330,190246,1191,2905,783,241,92,36,0,1,12,4,414,1634,3771,12613,6599,58937,147444,114700,763,261,4,0,5,3,2297,5895,43,21,18408,14360,5,11,202,310,849,1199,330803,193485,8640,7744,160,96,793,231,3068,13316,1,3,31340,1428,15,1,840,184,0,1,41,23,1,1,76,180,870,154,41121,24415,1,3,3024,13360,5347,60189,1,1,27,997,2,6,499,7693,0,2,3,1,19,13,53547,11989,39,89,1733,2363,4,12,922,102,40,24,14442,18326,3900,196,132,124,59,5,7,1,29262,36274,18,46,14,2,744,1304,79,49,46769,1001807,0,1,1092,15292,404921,119367,10275,22493,318,706,3789,307,643,1405,27748,37788,73529,188615,915,1133,63209,2327,63,1,34,30,510,514,31,1,2,0,0,8,53949,11587,1072,976,2272,30496,4067,4125,1,1,8,8,2,14,0,2,123519,925057,1,15,111,145,26,38,980565,68011,47,81,9016,7368,1458,6734,8656,7728,486960,561616,551,473,6,2,2,6,60,4,649,375,3756,340,69740,192404,238386,23758,80,176,126250,4822,481744,42544,98,30,1,0,13,3,149,1899,3926,170,1805,6387,24842,7926,18,46,279074,245214,272,1776,480543,568033,1829,219,745,1303,1860,188,4441,28327,99,29,46348,19188,138,118,4,4,86613,175531,2884,5308,2410,1686,4090,4102,5933,2259,0,2,93,419,1,1,16302,507986,877357,171219,0,1,4,0,8706,7678,17,15,49216,16320,210,46,9,23,16384,0,27,37,6491,255653,4,0,386,1662,9739,55797,185,327,4938,3254,35,221,7414,778,1943,6249,13,3,8,24,776,31992,817125,231451,17801,14967,2,0,6897,1295,26,6,57095,8441,142721,119423,43074,481214,30,2,669447,379129,8671,24097,7,9,12,116,2,0,30030,2738,2533,128539,1,7,6,10,369133,155155,1955,2141,0,1,875,1173,165,91,5995,2197,28,4,0,1,30233,2535,1171,2925,17,47,7,1,175,849,1,1,800,224,7780,412,82,430,893191,155385,3,5,45,83,104,24,2779,1317,19946,504342,259,7933,1,3,11664,119408,1173,2923,16,0,113892,934684,17,47,35812,29724,10,6,450,62,53,75,130124,948,1777,6415,42,86,1692,2404,129831,1241,59,5,32,96,73,55,112385,149759,9,7,3008,1088,21122,11646,4,4,1,3,52589,995987,110557,151587,9713,55823,587382,461194,502921,545655,9417,6967,687456,361120,0,8,2,14,123,5,100,412,15042,1342,206179,842397,22,10,2263,1833,2,0,60985,4551,82,174,165,91,0,512,68335,62737,106,406,18,14,730,1318,13,51,15110,1274,4,0,220,1828,408745,115543,6535,1657,0,2,127123,3949,314,710,3,1,0,1,7080,25688,21106,11662,10,502,26,38,290,734,29629,3139,32987,98085,0,2,2,2,62,2,29204,3564,8,0,109,147,93797,37275,28014,4754,631,393,524088,524488,23,489,12,52,19700,13068,1,3,64913,623,119356,142788,123937,138207,27716,37820,3,61,3584,4608,60,4,1,1,183,73,48,464,31252,34284,119991,142153,3,5,766945,281631,0,4,6803,9581,5,3,5249,2943,8,8,6297,1895,62195,199949,465,47,11,21,26,230,9311,23457,1,1,159,353,107,21,243430,805146,250,774,6263,1929,160320,101824,0,8,16689,48847,934,261210,1,3,3186,910,446180,602396,308,3788,17,15,7,9,5,3,4647,28121,10,6,0,2,1100,2996,44,20,103140,159004,118,10,0,4,0,1,30,2,8,0,129650,1422,4350,126722,25,7,1,31,23109,9659,1,0,2,2,0,16,22,42,788,236,114,142,28793,36743,558,1490,1,0,16,112,2983,1113,7,1,23,41,7137,1055,741,1307,197725,64419,6,2,9,7,147126,377162,178769,345519,635,1413,28324,37212,10559,54977,400,112,2,6,388,124,349,675,38147,92925,11,5,636253,412323,30237,2531,13,3,38,90,3447,4745,101134,161010,160,96,6078,26690,0,1,0,32,40,472,714,1334,0,1,152,872,4,4,90838,40234,132,124,943,81,11153,250991,89,167,545,1503,98171,32901,409,1639,1307,741,3078,5114,4000,12384,11,21,7,1,24,40]],
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    // var_dump($data);

    $obj = new Solution();
    $result = $obj->countPairs(...$data);
    // $result = $obj->($xhprof->tree($data));
    // $result = $obj->($xhprof->listNode($data));
    // $result = $obj->find(...$data);
    // var_dump($result);
    if(count($result)<=20){
        var_dump($result);
    } else {
        var_dump(count($result));
    }
    echo str_repeat(PHP_EOL, 3);
    echo str_repeat("<br>", 3);
}

// foreach ($datas as $data){
//     $obj = new $data[0][0](...$data[1][0]);
//
//     for ($i=1; $i<count($data[0]); $i++){
//         $func = $data[0][$i];
//         $param = $data[1][$i];
//         $result = $obj->$func(...$param);
//
//         echo $data[0][$i] ."(\"". implode(",", $data[1][$i]) ."\") ";
//             if($result === true){
//                 echo "True";
//             } elseif($result === false) {
//                 echo "False";
//             } elseif($result === null) {
//                 echo "Null";
//             } elseif(is_array($result)) {
//                 var_dump($result);
//             } else {
//                 echo $result;
//             }
//         echo PHP_EOL;
//     }
//
//     echo str_repeat(PHP_EOL, 3);
// }
$xhprof->end();
